package saas.consumer.service.remote.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;

/**
 * @author guan.xin
 * @title BzRequestInterceptor
 * @description
 * @create 2022-04-25 17:45
 * @since JDK8
 */
@Slf4j
public class BzRequestInterceptor implements RequestInterceptor {

    private static final String SENTINEL_AUTHORITY_ORIGIN_NAME = "sentinel-authority-origin";

    private static final String SENTINEL_AUTHORITY_ORIGIN_VALUE = "oms4-tp-sdk";

    @Override
    public void apply(RequestTemplate requestTemplate) {
        // 放入鉴权Token
        requestTemplate.header(SENTINEL_AUTHORITY_ORIGIN_NAME, SENTINEL_AUTHORITY_ORIGIN_VALUE);
        log.info("请求头放置数据：{}:{}", SENTINEL_AUTHORITY_ORIGIN_NAME, SENTINEL_AUTHORITY_ORIGIN_VALUE);
    }
}
